//获取应用实例 
const app = getApp();

Page({
	data: {
    userimg:'',
    nickname:'修改',
    avatar: '',
    version_android: '',
  },
	onLoad: function(option) {
    // this.setData({
    //   version_android: app.globalData.version_code
    // })
    // let {
    //   avatar
    // } = option

    // if (avatar) {
    //   this.setData({
    //     userimg: avatar
    //   })
    //   this.upload_file(avatar)
    // }
   
  },

  onShow:function(){
    // this.getUserMsg();
  },


  //退出登录
  logout:function(){
    var that = this;
    wx.request({
      url: app.globalData.api + '/app.php?c=User&a=loginout',
      method: 'post',
      header: {
        "Content-Type": "application/x-www-form-urlencoded",
        'platform': '' + app.globalData.platform,
        'version': '' + app.globalData.version,
      },
      data: {
        'token': ''+app.globalData.token
      },
      success: (res) => {
        console.log(res)
        if(res.data.code==0){
          wx.removeStorage({
            key: 'token',
            success: function (res) {
              console.log(res)
            },
          })
          wx.removeStorage({
            key: 'uid',
            success: function (res) {
              console.log(res)
            },
          })
          app.globalData.token = '';
          app.globalData.uid="";
          wx.reLaunch({
            url: '/pages/mine/phone-login',
          })
        }else{
          wx.showToast({
            title: ''+res.data.msg,
            icon:"none"
          })
        }
      },
    });
  },
});
